//-----------------------------------------------------------------------------
//  Copyright (C) 2005-2008 Thomas S. Ullrich 
//
//  This file is part of the Solitaire Mahjong project.
//
//  This file may be used under the terms of the GNU General Public License.
//  This project is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License.
//  
//  Author: Thomas S. Ullrich
//  Last update: June 1, 2007
//-----------------------------------------------------------------------------
#ifndef smTileItem_h
#define smTileItem_h
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include "smDefinitions.h"
 
class smTileItem : public QGraphicsPixmapItem
{
public:
    smTileItem(QGraphicsScene* scene,
	           const QImage* normal,
			   const QImage* highlight,
			   int id);
   ~smTileItem();
 
   int column() const;
   int row() const;
   int index() const;
   int layer() const;
   int id()const;
   int width() const;
   int height() const;
   double xOffset() const;
   double yOffset() const;
   bool   highlighted() const;
 
   void remove();      // hide and redraw
   void undoRemove();
 
   void setColumn(int);
   void setRow(int);
   void setIndex(int);
   void setLayer(int);
   void setXOffset(int);
   void setYOffset(int);
   void setHighlighted(bool);
   static void setUpdateEnabled(bool);
   
private:
    QPixmap  mNormalPixmap;
    QPixmap  mHighlightPixmap;
    int      mTileId;
    int      mColumn;
    int      mRow;
    int      mLayer;
    double   mXOffset;
    double   mYOffset;
    int      mIndex;
    bool     mIsHighlighted;
    static bool mUpdateEnabled;
    
    friend class smPlayedTilesList;
};

inline int smTileItem::column() const {return mColumn;}
inline int smTileItem::row() const {return mRow;}
inline int smTileItem::index() const {return mIndex;}
inline int smTileItem::layer() const {return mLayer;}
inline int smTileItem::id()const {return mTileId;}
inline double smTileItem::xOffset() const {return mXOffset;}
inline double smTileItem::yOffset() const {return mYOffset;}
inline bool smTileItem::highlighted() const {return mIsHighlighted;}
 
inline void smTileItem::setColumn(int val) {mColumn = val;}
inline void smTileItem::setRow(int val) {mRow = val;}
inline void smTileItem::setIndex(int val) {mIndex = val;}
inline void smTileItem::setLayer(int val) {mLayer = val;}
inline void smTileItem::setXOffset(int val) {mXOffset = val;}
inline void smTileItem::setYOffset(int val) {mYOffset = val;}
inline void smTileItem::setUpdateEnabled(bool val) {mUpdateEnabled = val;}
 
#endif
